Randomized algorithm